package com.zmm.myyimixian.ui.activity.search.presenter;

import com.zmm.myyimixian.bean.SearchBean;
import com.zmm.myyimixian.ui.activity.search.model.OnLoadSearchBeanListener;
import com.zmm.myyimixian.ui.activity.search.model.SearchModelImpl;
import com.zmm.myyimixian.ui.activity.search.view.ISearchView;

/**
 * Created by Administrator on 2016/10/24 0024.
 * presenter接口的实现类
 */

public class SearchPresenterIml implements ISearhPresenter {
    //数据
    private SearchModelImpl model;
    //视图
    private ISearchView mView;

    public SearchPresenterIml(ISearchView view) {
        model = new SearchModelImpl();
        this.mView = view;
    }

    @Override
    public void loadData() {
        mView.showProgress();
        //获取数据
        model.loadSearchBean(mView.getPath(), new OnLoadSearchBeanListener() {
            @Override
            public void onSuccess(SearchBean searchBean) {
                mView.addSearchBean(searchBean);//请求成功
                mView.hideProgress();
            }

            @Override
            public void onFailure(String msg, Throwable e) {
                mView.showLoadFailMsg();//请求失败
                mView.hideProgress();
            }
        });
    }
}
